import {observable} from 'mobx';
import {Boundary} from "./boundary";

export const OffsetStore = observable({
  x:0,
  y:0,
  setOffsetX(value: number) {
    if(value > Boundary.left && value < Boundary.right){
      this.x = value;
    }else if(value < Boundary.left){
      this.x = Boundary.left;
    }else{
      this.x = Boundary.right;
    }
  },

  setOffsetY(value: number) {
    if(value < Boundary.top && value > Boundary.bottom){
      this.y = value;
    }else if(value > Boundary.top){
      this.y = Boundary.top;
    }else{
      this.y = Boundary.bottom;
    }
  },

  setOffset(x: number, y:number){
    this.setOffsetX(x);
    this.setOffsetY(y);
  },

  // isInView(x: number, y: number){
  //   const sysInfo = Taro.getSystemInfoSync();
  //   const windowWidth = sysInfo.windowWidth;
  //   const windowHeight = sysInfo.windowHeight;
  //   const viewRange = {
  //     left: this.x,
  //     right: this.x + windowWidth,
  //   };
  // }
});
